﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RRRSRoguelike.Managers;
using RRRSRoguelikeData;
using RRRSRoguelike.Enums;
using System.Diagnostics;
using RRRSRoguelike.Helpers;
using RRRSRoguelike.Helpers.Visualizer;
using System.Drawing;

namespace RRRSRoguelike.Screens
{
    /// <summary>
    /// Manages the UI to enter Random Seed Number to start.
    /// </summary>
    class MenuScreen:Screen
    {
    	Menu menu = new Menu();
    	
        public MenuScreen()
        {
        	//Setup one panel to fill screen
            PanelList.Add(new Panel(new Point(4, 3), 
                Visualizer.GetScreenWidth() - 9, Visualizer.GetScreenHeight() - 6));    

        	SetupMenu();
        }
        
		void SetupMenu()
		{
			menu.Add(new MenuItem(Properties.Strings.StartGame,new EventHandler(SelectNewGame)));
        	menu.Add(new MenuItem(Properties.Strings.EnterSeed,new EventHandler(SelectSeed)));
        	menu.Add(new MenuItem(Properties.Strings.SelectLanguage,new EventHandler(SelectLanguage)));
        	menu.Add(new MenuItem(Properties.Strings.Exit,new EventHandler(SelectExit)));
		}
        
                     
                        
        #region Methods
        
        public override void Show()
        {
        	Draw();
        	while(active)
        	{
        		if(menu.HandleInput())
        		menu.DrawMenu(PanelList[0]);
        	}
        }
                
        void Draw()
        {
			Clear();
        	PanelList[0].Draw();
        	menu.DrawMenu(PanelList[0]);
        }
        
        //Event method
        void SelectNewGame(object sender,EventArgs e)
        {
        	GameManager.Instance.ScreenStack.Push(new VanillaDungeonScreen());
        	active = false;
        }
        //Event method
        void SelectSeed(object sender,EventArgs e)
        {
        	GameManager.Instance.ScreenStack.Push(new SeedScreen());
        	active = false;
        }
        //Event method        
        void SelectLanguage(object sender,EventArgs e)
        {
        	new LanguageScreen().Show();
        	//Draw();
        	Clear();
        	PanelList[0].Draw();
        }
		//Event method
        void SelectExit(object sender,EventArgs e)
        {
        	GameManager.Instance.Exit();
        }   
        
        #endregion
    }
}
